class OrderMaintainItemsController < ApplicationController
  def new
  	@order_maintain_item = OrderMaintainItem.new
    @maintain_items = MaintainItem.all
    @maintain_styles = MaintainStyle.all
  end

  def create
  	@order_maintain_item = OrderMaintainItem.new post_params
    if @order_maintain_item.save
       redirect_to order_maintain_path(:id =>@order_maintain_item.order_maintain.id)
    else
      render :action => 'new'
    end
  end

  def destroy
    @order_maintain_item = OrderMaintainItem.find params[:id]
    @order_maintain_item.destroy
    redirect_to order_maintain_path(:id =>@order_maintain_item.order_maintain.id)
  end

   def post_params
    params.require(:order_maintain_item).permit(*%w(order_maintain_id maintain_item_id maintain_style_id))
  end
end
